Skip to contentSkip to conversation

Change in openvpn[master]: create and (sym)link compile_commands.json file

Openvpn-devel In review d12fk (Code Review) 3 participants 11 messages Dec 16, 2023 – Dec 20, 2023 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1702721837000.Ib14c1161b4b0c9df797b9932ad14739e202cea64@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/483?usp=email

to review the following change.

Change subject: create and (sym)link compile_commands.json file
......................................................................

create and (sym)link compile_commands.json file

CMake has support to create a json file which contains exact information how each file in the project is compiled. This file can be consumed by clangd, which in turn provides precise symbol information to IDEs for better code navigation and contextual information.

I use it with vscode to be able to quickly switch between native Linux and mingw builds and have the symbols info change dynamically with it. So handy that I think it is useful for others as well.

Change-Id Ib14c1161b4b0c9df797b9932ad14739e202cea64

---
M CMakeLists.txt

1 file changed, 6 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/83/483/1

CMakeLists.txt +6 -1
index d40b213..bc46c27 100644
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.14)
 set(CMAKE_CONFIGURATION_TYPES "Release;Debug;ASAN")
 project(openvpn)
 
@@ -42,6 +42,11 @@
 
 set(PLUGIN_DIR /usr/local/lib/openvpn/plugins CACHE FILEPATH "Location of the plugin directory")
 
+# Create machine readable compile commands
+set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+file(CREATE_LINK ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
+                 ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json SYMBOLIC)
+
 # AddressSanitize - use CXX=clang++ CC=clang cmake -DCMAKE_BUILD_TYPE=asan to build with ASAN
 set(CMAKE_C_FLAGS_ASAN
     "-fsanitize=address,undefined -fno-sanitize-recover=all -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/483?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib14c1161b4b0c9df797b9932ad14739e202cea64
Gerrit-Change-Number: 483
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: cmake: create and link compile_commands.json file

In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/483?usp=email

to look at the new patch set (#2).

Change subject: cmake: create and link compile_commands.json file
......................................................................

cmake: create and link compile_commands.json file

CMake has support to create a json file which contains exact information how each file in the project is compiled. This file can be consumed by clangd, which in turn provides precise symbol information to IDEs for better code navigation and contextual information.

I use it with vscode to be able to quickly switch between native Linux and mingw builds and have the symbols info change dynamically with it. So handy that I think it is useful for others as well.

Change-Id Ib14c1161b4b0c9df797b9932ad14739e202cea64

---
M CMakeLists.txt

1 file changed, 6 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/83/483/2

CMakeLists.txt +6 -1
index d40b213..bc46c27 100644
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.14)
 set(CMAKE_CONFIGURATION_TYPES "Release;Debug;ASAN")
 project(openvpn)
 
@@ -42,6 +42,11 @@
 
 set(PLUGIN_DIR /usr/local/lib/openvpn/plugins CACHE FILEPATH "Location of the plugin directory")
 
+# Create machine readable compile commands
+set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+file(CREATE_LINK ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
+                 ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json SYMBOLIC)
+
 # AddressSanitize - use CXX=clang++ CC=clang cmake -DCMAKE_BUILD_TYPE=asan to build with ASAN
 set(CMAKE_C_FLAGS_ASAN
     "-fsanitize=address,undefined -fno-sanitize-recover=all -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/483?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib14c1161b4b0c9df797b9932ad14739e202cea64
Gerrit-Change-Number: 483
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#3 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: cmake: create and link compile_commands.json file

In reply to a message not in the archive

Attention is currently required from: d12fk, plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/483?usp=email )

Change subject: cmake: create and link compile_commands.json file
......................................................................

Patch Set 2: Code-Review-1

(1 comment)

File CMakeLists.txt:

http://gerrit.openvpn.net/c/openvpn/+/483/comment/11405220_078560e2 :
PS2, Line 1: cmake_minimum_required(VERSION 3.14)
Please document in the commit message why you increased this. This is for CREATE_LINK, correct?

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/483?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib14c1161b4b0c9df797b9932ad14739e202cea64
Gerrit-Change-Number: 483
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Mon, 18 Dec 2023 11:18:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#4 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: cmake: create and link compile_commands.json file

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, plaisthos.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/483?usp=email

to look at the new patch set (#3).

The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld

Change subject: cmake: create and link compile_commands.json file
......................................................................

cmake: create and link compile_commands.json file

CMake has support to create a json file which contains exact information how each file in the project is compiled. This file can be consumed by clangd, which in turn provides precise symbol information to IDEs for better code navigation and contextual information.

I use it with vscode to be able to quickly switch between native Linux and mingw builds and have the symbols info change dynamically with it. So handy that I think it is useful for others as well.

Bump required CMake version for CREATE_LINK.

Change-Id Ib14c1161b4b0c9df797b9932ad14739e202cea64

---
M CMakeLists.txt

1 file changed, 6 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/83/483/3

CMakeLists.txt +6 -1
index d40b213..bc46c27 100644
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.14)
 set(CMAKE_CONFIGURATION_TYPES "Release;Debug;ASAN")
 project(openvpn)
 
@@ -42,6 +42,11 @@
 
 set(PLUGIN_DIR /usr/local/lib/openvpn/plugins CACHE FILEPATH "Location of the plugin directory")
 
+# Create machine readable compile commands
+set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+file(CREATE_LINK ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
+                 ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json SYMBOLIC)
+
 # AddressSanitize - use CXX=clang++ CC=clang cmake -DCMAKE_BUILD_TYPE=asan to build with ASAN
 set(CMAKE_C_FLAGS_ASAN
     "-fsanitize=address,undefined -fno-sanitize-recover=all -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"
Signature · 16 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/483?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib14c1161b4b0c9df797b9932ad14739e202cea64
Gerrit-Change-Number: 483
Gerrit-PatchSet: 3
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-MessageType: newpatchset
#5 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: cmake: create and link compile_commands.json file

In reply to a message not in the archive

Attention is currently required from: d12fk, plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/483?usp=email )

Change subject: cmake: create and link compile_commands.json file
......................................................................

Patch Set 3: Code-Review+2

(1 comment)

File CMakeLists.txt:

http://gerrit.openvpn.net/c/openvpn/+/483/comment/7ad1e93a_33c407bc :
PS2, Line 1: cmake_minimum_required(VERSION 3.14)

Quoted 1 line

Please document in the commit message why you increased this. […]

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/483?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib14c1161b4b0c9df797b9932ad14739e202cea64
Gerrit-Change-Number: 483
Gerrit-PatchSet: 3
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Mon, 18 Dec 2023 14:17:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment

#6 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: cmake: create and link compile_commands.json file

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, plaisthos.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/483?usp=email

to look at the new patch set (#4).

The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld

The change is no longer submittable: Code-Review and checks~ChecksSubmitRule are unsatisfied now.

Change subject: cmake: create and link compile_commands.json file
......................................................................

cmake: create and link compile_commands.json file

CMake has support to create a json file which contains exact information how each file in the project is compiled. This file can be consumed by clangd, which in turn provides precise symbol information to IDEs for better code navigation and contextual information.

I use it with vscode to be able to quickly switch between native Linux and mingw builds and have the symbols info change dynamically with it. So handy that I think it is useful for others as well.

Bump required CMake version for CREATE_LINK.

Change-Id Ib14c1161b4b0c9df797b9932ad14739e202cea64

---
M .gitignore
M CMakeLists.txt

2 files changed, 7 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/83/483/4

.gitignore +1 -0
index a1da366..4153a3e 100644
@@ -40,6 +40,7 @@
 m4/ltversion.m4
 m4/lt~obsolete.m4
 
+compile_commands.json
 doc/openvpn-examples.5
 doc/openvpn-examples.5.html
 doc/openvpn.8
CMakeLists.txt +6 -1
index d40b213..bc46c27 100644
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.14)
 set(CMAKE_CONFIGURATION_TYPES "Release;Debug;ASAN")
 project(openvpn)
 
@@ -42,6 +42,11 @@
 
 set(PLUGIN_DIR /usr/local/lib/openvpn/plugins CACHE FILEPATH "Location of the plugin directory")
 
+# Create machine readable compile commands
+set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+file(CREATE_LINK ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
+                 ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json SYMBOLIC)
+
 # AddressSanitize - use CXX=clang++ CC=clang cmake -DCMAKE_BUILD_TYPE=asan to build with ASAN
 set(CMAKE_C_FLAGS_ASAN
     "-fsanitize=address,undefined -fno-sanitize-recover=all -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/483?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib14c1161b4b0c9df797b9932ad14739e202cea64
Gerrit-Change-Number: 483
Gerrit-PatchSet: 4
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-MessageType: newpatchset

#7 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: cmake: create and link compile_commands.json file

In reply to a message not in the archive

Attention is currently required from: d12fk, plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/483?usp=email )

Change subject: cmake: create and link compile_commands.json file
......................................................................

Patch Set 4: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/483?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib14c1161b4b0c9df797b9932ad14739e202cea64
Gerrit-Change-Number: 483
Gerrit-PatchSet: 4
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Wed, 20 Dec 2023 11:41:04 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#8 lore raw

PATCH v4 1/1 cmake: create and link compile_commands.json file

In reply to a message not in the archive

From: Heiko Hund <[email protected]...>

CMake has support to create a json file which contains exact information how each file in the project is compiled. This file can be consumed by clangd, which in turn provides precise symbol information to IDEs for better code navigation and contextual information.

I use it with vscode to be able to quickly switch between native Linux and mingw builds and have the symbols info change dynamically with it. So handy that I think it is useful for others as well.

Bump required CMake version for CREATE_LINK.

Change-Id Ib14c1161b4b0c9df797b9932ad14739e202cea64

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/483
This mail reflects revision 4 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>

.gitignore +1 -0
index a1da366..4153a3e 100644
@@ -40,6 +40,7 @@
 m4/ltversion.m4
 m4/lt~obsolete.m4
 
+compile_commands.json
 doc/openvpn-examples.5
 doc/openvpn-examples.5.html
 doc/openvpn.8
CMakeLists.txt +6 -1
index d40b213..bc46c27 100644
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.14)
 set(CMAKE_CONFIGURATION_TYPES "Release;Debug;ASAN")
 project(openvpn)
 
@@ -42,6 +42,11 @@
 
 set(PLUGIN_DIR /usr/local/lib/openvpn/plugins CACHE FILEPATH "Location of the plugin directory")
 
+# Create machine readable compile commands
+set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+file(CREATE_LINK ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
+                 ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json SYMBOLIC)
+
 # AddressSanitize - use CXX=clang++ CC=clang cmake -DCMAKE_BUILD_TYPE=asan to build with ASAN
 set(CMAKE_C_FLAGS_ASAN
     "-fsanitize=address,undefined -fno-sanitize-recover=all -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"
#9 lore raw

[Openvpn-devel] [PATCH applied] Re: cmake: create and link compile_commands.json file

Since this is build system (-only) and won't affected generated code, I have not tested it. I have an ACK, and the buildbots are happy with it.

Your patch has been applied to the master branch.

commit 855030f3d76324bdb614c05ec0ca5b86d66653bb

Author: Heiko Hund
Date:   Wed Dec 20 13:36:59 2023 +0100
     cmake: create and link compile_commands.json file

     Signed-off-by: Heiko Hund <[email protected]...>
     Acked-by: Frank Lichtenheld <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg27840.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#10 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: cmake: create and link compile_commands.json file

In reply to a message not in the archive

cron2 has uploaded a new patch set (#5) to the change originally created by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/483?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld

Change subject: cmake: create and link compile_commands.json file
......................................................................

cmake: create and link compile_commands.json file

CMake has support to create a json file which contains exact information how each file in the project is compiled. This file can be consumed by clangd, which in turn provides precise symbol information to IDEs for better code navigation and contextual information.

I use it with vscode to be able to quickly switch between native Linux and mingw builds and have the symbols info change dynamically with it. So handy that I think it is useful for others as well.

Bump required CMake version for CREATE_LINK.

Change-Id Ib14c1161b4b0c9df797b9932ad14739e202cea64

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27840.html

---
M .gitignore
M CMakeLists.txt

2 files changed, 7 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/83/483/5

.gitignore +1 -0
index a1da366..4153a3e 100644
@@ -40,6 +40,7 @@
 m4/ltversion.m4
 m4/lt~obsolete.m4
 
+compile_commands.json
 doc/openvpn-examples.5
 doc/openvpn-examples.5.html
 doc/openvpn.8
CMakeLists.txt +6 -1
index d40b213..bc46c27 100644
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.14)
 set(CMAKE_CONFIGURATION_TYPES "Release;Debug;ASAN")
 project(openvpn)
 
@@ -42,6 +42,11 @@
 
 set(PLUGIN_DIR /usr/local/lib/openvpn/plugins CACHE FILEPATH "Location of the plugin directory")
 
+# Create machine readable compile commands
+set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+file(CREATE_LINK ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
+                 ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json SYMBOLIC)
+
 # AddressSanitize - use CXX=clang++ CC=clang cmake -DCMAKE_BUILD_TYPE=asan to build with ASAN
 set(CMAKE_C_FLAGS_ASAN
     "-fsanitize=address,undefined -fno-sanitize-recover=all -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/483?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib14c1161b4b0c9df797b9932ad14739e202cea64
Gerrit-Change-Number: 483
Gerrit-PatchSet: 5
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#11 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: cmake: create and link compile_commands.json file

In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/483?usp=email )

Change subject: cmake: create and link compile_commands.json file
......................................................................

cmake: create and link compile_commands.json file

CMake has support to create a json file which contains exact information how each file in the project is compiled. This file can be consumed by clangd, which in turn provides precise symbol information to IDEs for better code navigation and contextual information.

I use it with vscode to be able to quickly switch between native Linux and mingw builds and have the symbols info change dynamically with it. So handy that I think it is useful for others as well.

Bump required CMake version for CREATE_LINK.

Change-Id Ib14c1161b4b0c9df797b9932ad14739e202cea64

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27840.html

---
M .gitignore
M CMakeLists.txt

2 files changed, 7 insertions(+), 1 deletion(-)
.gitignore +1 -0
index a1da366..4153a3e 100644
@@ -40,6 +40,7 @@
 m4/ltversion.m4
 m4/lt~obsolete.m4
 
+compile_commands.json
 doc/openvpn-examples.5
 doc/openvpn-examples.5.html
 doc/openvpn.8
CMakeLists.txt +6 -1
index d40b213..bc46c27 100644
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.14)
 set(CMAKE_CONFIGURATION_TYPES "Release;Debug;ASAN")
 project(openvpn)
 
@@ -42,6 +42,11 @@
 
 set(PLUGIN_DIR /usr/local/lib/openvpn/plugins CACHE FILEPATH "Location of the plugin directory")
 
+# Create machine readable compile commands
+set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+file(CREATE_LINK ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
+                 ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json SYMBOLIC)
+
 # AddressSanitize - use CXX=clang++ CC=clang cmake -DCMAKE_BUILD_TYPE=asan to build with ASAN
 set(CMAKE_C_FLAGS_ASAN
     "-fsanitize=address,undefined -fno-sanitize-recover=all -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/483?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib14c1161b4b0c9df797b9932ad14739e202cea64
Gerrit-Change-Number: 483
Gerrit-PatchSet: 5
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged